package com.ssy.lingxi.product.entity.commodity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ssy.lingxi.product.handler.converter.JpaStringToArrayConverter;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 商品描述
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/8/10
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_commodity_remark")
public class CommodityRemark implements Serializable {
    private static final long serialVersionUID = 7019667142076510598L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="commodity_remark_seq")
    @SequenceGenerator(sequenceName="product_commodity_remark_seq", name="commodity_remark_seq",allocationSize = 1)
    private Long id;

    /**
     * 图片
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "commodityRemark", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<CommodityRemarkImage> imageList;

    /**
     * 视频
     */
    @Column(columnDefinition = "text")
    @Convert(converter = JpaStringToArrayConverter.class)
    private String[] video;

    /**
     * 文字
     */
    @Column(columnDefinition = "text")
    @Convert(converter = JpaStringToArrayConverter.class)
    private String[] word;
}
